﻿@model IEnumerable<BTKERP.Model.Unit>

@{
    ViewBag.Title = "Unit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section AdditionalJS
{
    <script type="text/javascript">
//        $(document).ready(function () {
//            var trs = $("#dt tr");
//            trs.each(function () {
//                $(this).bind("mouseover", function () {
//                    $(this).css("backgroundColor", "yellow");
//                }).bind("mouseout", function () {
//                    $(this).css("backgroundColor", "white");
//                });
//            });
//        });
        $(function () {
            $("#requisitionDate, #fullfilledDate").datepicker();
            $("#btnSave").button();
        });

        function createNewUnit() {
            //$("#dialog").dialog({ width: "auto" });
            window.location = "/Unit/Create"; 
        }
    </script>

}
<h2>Unit</h2>
<input type="button" value="Create New"  class="btn btn-green" onclick="createNewUnit()" />
<div id="dialog" title="Unit Details" style="display:none">Unit Details
<table class="editor stylized">
<thead>
  <tr>
        <th>
            Name
        </th>
        <th>
            Description
        </th>
        <th>
            UnitType
        </th>
  </tr>
</thead>
<tbody>
    <tr>
        <td>
            <input type="text" />
        </td>
        <td>
            <input type="text" />
        </td>
        <td>
            @Html.DropDownList("unittype")
        </td>
    </tr>
    <tr>
      <td colspan="3" class="ta-center">
        <input type="button" class="btn btn-blue" value="Submit" />
      </td>
    </tr>
</tbody>

</table>

</div>
<table id="dt" class="display stylized">
    <tr>
        <th>
            Name
        </th>
        <th>
            Description
        </th>
        <th>
            UnitType
        </th>
        <th></th>
    </tr>
@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Description)
        </td>
        <td>
            @BTKERP.MVCWeb.AppCode.DataRefHelper.GetUnitTypeById(item.UnitTypeId)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.Id })
        </td>
    </tr>
}
</table>
